# -*- coding: utf-8 -*-
$:.push('gen-rb')

require 'thrift'
require 'user_constants'
require 'user_storage'

begin
  transport = Thrift::BufferedTransport.new(Thrift::Socket.new('0.0.0.0', '9090'))
  protocol = Thrift::BinaryProtocol.new(transport)
  client = Model::UserStorage::Client.new(protocol)
  transport.open()

  user = Model::User.new(:id => 1, :name => 'foo')

  puts client.set_user(user).inspect # => nil
  puts client.get_user(2).inspect # => <Model::User id:2, name:"Name: 2">

  transport.close()
rescue Thrift::TransportException => e
  puts "Thrift::Exception: #{e.message}"
end
